package cn.gson.springboot.controller.presalecontroller;

import cn.gson.springboot.model.pjos.Offer;
import cn.gson.springboot.model.pjos.OfferDetails;
import cn.gson.springboot.model.pjos.SpeedInfo;
import cn.gson.springboot.model.service.presaleservice.PsBusinessDatailsTwoService;
import cn.gson.springboot.model.vo.privilegevo.ApprovalPosition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 商机详情2controller
 */
@Controller
@RequestMapping("/buDetailsTwo")
public class PsBusinessDatailsTwoController {
    @Autowired
    PsBusinessDatailsTwoService businessDatailsTwoService;//注入商机详情2业务类

    @RequestMapping("/addBusinessDetails")
    @ResponseBody
    public void saveDatails(String details){
        businessDatailsTwoService.saveDetails(details);
    }

    //报价单号
    @RequestMapping("/offerNumber")
    @ResponseBody
    public String selectMaxOfferNumber(){
        return businessDatailsTwoService.selectMaxOfferNumber();
    }

    /*查询商机下的报价单*/
    @RequestMapping("business_offer")
    @ResponseBody
    public List<Offer> selectBusinessOffer(Integer businesId){
        return businessDatailsTwoService.selectBusinessOffer(businesId);
    }
    @RequestMapping("/saveOffer")
    @ResponseBody
    public int saveOffer(String offerData){
        System.err.println("报价单:"+offerData);
       return businessDatailsTwoService.saveOffer(offerData);
    }
    @RequestMapping("/offerOne")
    @ResponseBody
    public Offer offerOne(Integer offerId){
        return businessDatailsTwoService.offerOne(offerId);
    }
    @RequestMapping("/offerTwo")
    @ResponseBody
    public List<OfferDetails> offerTwo(Integer offerId){
        return businessDatailsTwoService.offerTwo(offerId);
    }

    /*查询所有的商机进度*/
    @RequestMapping("/speed")
    @ResponseBody
    public List<SpeedInfo> allSpeed(){
        return businessDatailsTwoService.allSpeed();
    }

    /**拥有审批权限的人*/
    @RequestMapping("/approval")
    @ResponseBody
    public List<ApprovalPosition> findApprovaler(){
        return  businessDatailsTwoService.findApprovaler("审批");
    }
}
